package org.september.pisces.sms;

import org.september.pisces.module.api.PiscesModule;
import org.september.pisces.settings.service.PiscesSettingService;
import org.september.pisces.sms.enums.SmsSettingEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;


/**
 * 标注service，用于主工程发现插件模块
 * @author yexinzhou
 *
 */
@Configuration
@ComponentScan(basePackageClasses = PiscesSmsModule.class)
public class PiscesSmsModule implements PiscesModule {

	@Autowired
	private PiscesSettingService piscesSettingService;
	
	public PiscesSmsModule(){
		System.out.println(this.getClass().getName()+" init..");
	}

	public String[] getMyBatisMapperLocation() {
		return new String[] {"classpath:"+this.getClass().getPackageName().replace(".", "/")+"/mapper/*.xml"};
	}
	
	public String[] getEntityPackages() {
		return new String[] {this.getClass().getPackageName()+".entity"};
    }
	
	public void init() {
		//初始化配置项
		for(SmsSettingEnum em : SmsSettingEnum.values()) {
			piscesSettingService.getValueOrDefault(em);
		}
	}

}
